package j03zuoye;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

class Worker{
    /*
    .hualan.bean包里创建一个Worker类, 包含姓名name, 年龄age, 工资salary属性, 包含一个work方法(打印xx在工作, xx是name的值).
     */
    private String name;
    private  int age;
    private int salary;

    public Worker(String name, int age, int salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public void work(){
        System.out.println(name+"在工作");
    }

    @Override
    public String toString() {
        return "Worker{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", salary=" + salary +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }
}

public class J2Worker {
    public static void main(String[] args) {
        List<Worker> l1 = new ArrayList<>();
        l1.addAll(
                Arrays.asList(
                        new Worker("zhangsan",21,3000),
                        new Worker("lisi",25,3400),
                        new Worker("wangwu",22,3200)
                )
        );
        Iterator<Worker> it = l1.iterator();
        while (it.hasNext()){
            Worker temp = it.next();
            if(temp.getName().equals("wangwu")){
                it.remove();
            }

        }
        System.out.println("l1 = " + l1);
    }
}
